import Vue from 'vue'
import Router from 'vue-router'

Vue.use(Router)

/* Layout */
import Layout from '@/layout'

/**
 * Note: 路由配置项
 *
 * hidden: true                   // 当设置 true 的时候该路由不会再侧边栏出现 如401，login等页面，或者如一些编辑页面/edit/1
 * alwaysShow: true               // 当你一个路由下面的 children 声明的路由大于1个时，自动会变成嵌套的模式--如组件页面
 *                                // 只有一个时，会将那个子路由当做根路由显示在侧边栏--如引导页面
 *                                // 若你想不管路由下面的 children 声明的个数都显示你的根路由
 *                                // 你可以设置 alwaysShow: true，这样它就会忽略之前定义的规则，一直显示根路由
 * redirect: noRedirect           // 当设置 noRedirect 的时候该路由在面包屑导航中不可被点击
 * name:'router-name'             // 设定路由的名字，一定要填写不然使用<keep-alive>时会出现各种问题
 * meta : {
    roles: ['admin','editor']    // 设置该路由进入的权限，支持多个权限叠加
    title: 'title'               // 设置该路由在侧边栏和面包屑中展示的名字
    icon: 'svg-name'             // 设置该路由的图标，对应路径src/icons/svg
    breadcrumb: false            // 如果设置为false，则不会在breadcrumb面包屑中显示
  }
 */

// 公共路由
export const constantRoutes = [
  {
    path: '/redirect',
    component: Layout,
    hidden: true,
    children: [
      {
        path: '/redirect/:path(.*)',
        component: resolve => require(['@/views/redirect'], resolve)
      }
    ]
  },
  {
    path: '/login',
    component: resolve => require(['@/views/login'], resolve),
    hidden: true
  },
  {
    path: '/userCenter',
    component: resolve => require(['@/views/userCenter'], resolve),
    hidden: true
  },
  {
    path: '/404',
    component: resolve => require(['@/views/error/404'], resolve),
    hidden: true
  },
  {
    path: '/401',
    component: resolve => require(['@/views/error/401'], resolve),
    hidden: true
  },
  {
    path: '',
    component: Layout,
    redirect: 'index',
    children: [
      {
        path: 'index',
        component: resolve => require(['@/views/index'], resolve),
        name: '首页',
        meta: {
          title: '首页',
          icon: 'dashboard',
          noCache: true,
          affix: true
        }
      }
    ]
  },

  {
    path: '/menu',
    component: resolve => require(['@/views/system/menu/index'], resolve),
    hidden: true
  },

  {
    path: '/dict',
    component: Layout,
    hidden: true,
    children: [
      {
        path: 'type/data/:dictId(\\d+)',
        component: resolve => require(['@/views/system/dict/data'], resolve),
        name: 'Data',
        meta: { title: '字典数据', icon: '' }
      }
    ]
  },
  {
    path: '/job',
    component: Layout,
    hidden: true,
    children: [
      {
        path: 'log',
        component: resolve => require(['@/views/monitor/job/log'], resolve),
        name: 'JobLog',
        meta: { title: '调度日志' }
      }
    ]
  },
  {
    path: '/gen',
    component: Layout,
    hidden: true,
    children: [
      {
        path: 'edit/:tableId(\\d+)',
        component: resolve => require(['@/views/tool/gen/editTable'], resolve),
        name: 'GenEdit',
        meta: { title: '修改生成配置' }
      }
    ]
  },
  {
    path: '/class_video',
    component: Layout,
    hidden: true,
    children: [
      {
        path: '/eva_list',
        component: resolve =>
          require(['@/views/system/CompassVideoEva/index'], resolve),
        name: 'class_eva',
        meta: { title: '课程评价' }
      },
      {
        path: '/video_list',
        component: resolve =>
          require(['@/views/system/CompassVideoList/index'], resolve),
        name: 'video_list',
        meta: { title: '课程视频' }
      }
    ]
  },
  // 活动报名人员
  {
    path: '/act_user',
    component: Layout,
    hidden: true,
    children: [
      {
        path: 'list',
        component: resolve =>
          require(['@/views/system/CompassActUserRelation/index'], resolve),
        name: 'ActUsers',
        meta: { title: '报名详情' }
      }
    ]
  },

  // TODO 下面的OK了
  {
    path: '/notice',
    hidden: true,
    component: Layout,
    children: [
      {
        path: '/',
        component: resolve => require(['@/views/system/notice'], resolve),
        name: 'Notice',
        meta: { title: '公告管理', noCache: true }
      },
      {
        path: 'edit',
        hidden: true,
        component: resolve => require(['@/views/system/notice/edit'], resolve),
        name: 'NoticeEdit',
        meta: { title: '公告编辑', noCache: true }
      }
    ]
  },
  {
    path: '/news',
    hidden: true,
    component: Layout,
    children: [
      {
        path: '/',
        component: resolve => require(['@/views/system/news'], resolve),
        name: 'News',
        meta: { title: '资讯管理', noCache: true }
      },
      {
        path: 'edit',
        hidden: true,
        component: resolve => require(['@/views/system/news/edit'], resolve),
        name: 'NewsEdit',
        meta: { title: '资讯编辑', noCache: true }
      }
    ]
  },
  {
    path: '/feedback',
    component: Layout,
    hidden: true,
    children: [
      {
        path: '/',
        component: resolve => require(['@/views/system/feedback'], resolve),
        name: 'Feedback',
        meta: { title: '信息反馈', noCache: true }
      },
      {
        path: 'detail',
        component: resolve =>
          require(['@/views/system/feedback/detail'], resolve),
        name: 'FeedbackDetail',
        meta: { title: '意见详情', noCache: true }
      }
    ]
  },
  {
    path: '/goods',
    hidden: true,
    component: Layout,
    children: [
      {
        path: '/',
        component: resolve => require(['@/views/system/goods'], resolve),
        name: 'Goods',
        meta: { title: '产品管理', noCache: true }
      },
      {
        path: 'edit',
        hidden: true,
        component: resolve => require(['@/views/system/goods/edit'], resolve),
        name: 'GoodsEdit',
        meta: { title: '产品编辑', noCache: true }
      },
      {
        path: 'eva',
        hidden: true,
        component: resolve =>
          require(['@/views/system/CompassGoodsEva/index'], resolve),
        name: 'goodsEva',
        meta: { title: '产品评价', noCache: true }
      }
    ]
  },
  {
    path: '/activity',
    hidden: true,
    component: Layout,
    children: [
      {
        path: '/',
        component: resolve => require(['@/views/system/activity'], resolve),
        name: 'Activity',
        meta: { title: '活动管理', noCache: true }
      },
      {
        path: 'edit',
        hidden: true,
        component: resolve =>
          require(['@/views/system/activity/edit'], resolve),
        name: 'ActivityEdit',
        meta: { title: '活动编辑', noCache: true }
      }
    ]
  },
  {
    path: '/exCode',
    hidden: true,
    component: Layout,
    children: [
      {
        path: '/',
        component: resolve => require(['@/views/system/exCode/index'], resolve),
        name: 'exCode',
        meta: { title: '兑换码管理', icon: 'validCode', noCache: true }
      },
      {
        path: '/exCode/detail/:id',
        component: resolve =>
          require(['@/views/system/exCode/detail'], resolve),
        name: 'exCodeDetails',
        meta: { title: '兑换码详情', icon: 'validCode', noCache: true }
      }
    ]
  },
  {
    path: '/coupon',
    hidden: true,
    component: Layout,
    children: [
      {
        path: '/',
        component: resolve => require(['@/views/system/coupon/index'], resolve),
        name: 'Coupon',
        meta: { title: '优惠券列表', noCache: true }
      },
      {
        path: '/editCoupon',
        component: resolve => require(['@/views/system/coupon/add'], resolve),
        name: 'editCoupon',
        meta: { title: '优惠券管理', noCache: true }
      },
      {
        path: '/couponDetail',
        component: resolve =>
          require(['@/views/system/coupon/detail'], resolve),
        name: 'couponDetail',
        meta: { title: '优惠券详情', noCache: true }
      }
    ]
  },
  {
    path: '/CompassReport',
    hidden: true,
    component: Layout,
    children: [
      {
        path: '/',
        component: resolve =>
          require(['@/views/system/CompassReport/index'], resolve),
        name: 'CompassReport',
        meta: { title: '报告列表', noCache: true }
      },
      {
        path: '/editReport',
        component: resolve =>
          require(['@/views/system/CompassReport/edit'], resolve),
        name: 'EditReport',
        meta: { title: '报告处理', noCache: true }
      }
    ]
  },
  {
    path: '/advisor',
    component: Layout,
    hidden: true,
    children: [
      {
        path: '/',
        component: resolve => require(['@/views/system/advisor'], resolve),
        name: 'Advisor',
        meta: { title: '测评顾问', icon: 'advisor', noCache: true }
      },
      {
        path: 'edit',
        component: resolve => require(['@/views/system/advisor/edit'], resolve),
        name: 'AdvisorEdit',
        meta: { title: '编辑顾问', icon: 'advisor', noCache: true }
      }
    ]
  },
  {
    path: '/user',
    component: Layout,
    hidden: true,
    children: [
      {
        path: '/',
        component: resolve => require(['@/views/system/user'], resolve),
        name: 'User',
        meta: { title: '用户管理', icon: 'user', noCache: true }
      },
      {
        path: 'edit',
        component: resolve => require(['@/views/system/user/edit'], resolve),
        name: 'UserEdit',
        meta: { title: '编辑用户', icon: 'user', noCache: true }
      },
      {
        path: 'detail',
        component: resolve => require(['@/views/system/user/detail'], resolve),
        name: 'UserDetail',
        meta: { title: '用户详情', icon: 'user', noCache: true }
      }
    ]
  },
  {
    path: '/adminUser',
    component: Layout,
    hidden: true,
    children: [
      {
        path: '/',
        component: resolve => require(['@/views/system/adminUser'], resolve),
        name: 'AdminUser',
        meta: { title: '管理员', icon: 'adminUser', noCache: true }
      },
      {
        path: 'edit',
        component: resolve =>
          require(['@/views/system/adminUser/edit'], resolve),
        name: 'AdminUserEdit',
        meta: { title: '编辑管理员', icon: 'adminUser', noCache: true }
      }
    ]
  },
  {
    path: '/webSiteConfig',
    component: Layout,
    hidden: true,
    children: [
      {
        path: 'base',
        component: resolve =>
          require(['@/views/system/webSiteConfig/index'], resolve),
        name: 'Base',
        meta: { title: 'PC端基本信息', icon: 'banner', noCache: true }
      },
      {
        path: 'banner',
        component: resolve =>
          require(['@/views/system/webSiteConfig/banner'], resolve),
        name: 'Banner',
        meta: { title: '轮播图', icon: 'banner', noCache: true }
      },
      {
        path: 'banner/edit',
        component: resolve =>
          require(['@/views/system/webSiteConfig/banner/edit'], resolve),
        name: 'BannerEdit',
        meta: { title: '编辑轮播图', icon: 'banner', noCache: true }
      },
      {
        path: 'video',
        component: resolve =>
          require(['@/views/system/webSiteConfig/video'], resolve),
        name: 'Video',
        meta: { title: '宣传视频', icon: 'banner', noCache: true }
      },
      {
        path: 'successCase',
        component: resolve =>
          require(['@/views/system/webSiteConfig/successCase'], resolve),
        name: 'SuccessCase',
        meta: { title: '成功案例', icon: 'successCase', noCache: true }
      },
      {
        path: 'successCase/edit',
        component: resolve =>
          require(['@/views/system/webSiteConfig/successCase/edit'], resolve),
        name: 'SuccessCaseEdit',
        meta: {
          title: '编辑成功案例',
          icon: 'successCase',
          noCache: true
        }
      },
      {
        path: 'researchHistory',
        component: resolve =>
          require(['@/views/system/webSiteConfig/researchHistory'], resolve),
        name: 'ResearchHistory',
        meta: { title: '研发历史', icon: 'successCase', noCache: true }
      },
      {
        path: 'researchHistory/edit',
        component: resolve =>
          require([
            '@/views/system/webSiteConfig/researchHistory/edit'
          ], resolve),
        name: 'ResearchHistoryEdit',
        meta: {
          title: '编辑研发历史',
          icon: 'researchHistory',
          noCache: true
        }
      },
      {
        path: 'userServiceAgreement',
        component: resolve =>
          require([
            '@/views/system/webSiteConfig/userServiceAgreement'
          ], resolve),
        name: 'UserServiceAgreement',
        meta: {
          title: '用户服务协议',
          icon: 'userServiceAgreement',
          noCache: true
        }
      },
      {
        path: 'privacyPolicy',
        component: resolve =>
          require(['@/views/system/webSiteConfig/privacyPolicy'], resolve),
        name: 'PrivacyPolicy',
        meta: { title: '隐私政策', icon: 'privacyPolicy', noCache: true }
      },
      {
        path: 'legalNotice',
        component: resolve =>
          require(['@/views/system/webSiteConfig/legalNotice'], resolve),
        name: 'LegalNotice',
        meta: { title: '法律声明', icon: 'legalNotice', noCache: true }
      }
    ]
  },
  {
    path: '/setting',
    component: Layout,
    hidden: true,
    children: [
      {
        path: '/agreement',
        component: resolve =>
          require(['@/views/system/setting/agreement'], resolve),
        name: 'Agreement',
        meta: { title: '注册协议', icon: 'agreement', noCache: true }
      },
      {
        path: 'agreement/edit',
        component: resolve =>
          require(['@/views/system/setting/agreement/edit'], resolve),
        name: 'AgreementEdit',
        meta: { title: '编辑注册协议', icon: 'agreement', noCache: true }
      },
      {
        path: '/rotationImage',
        component: resolve =>
          require(['@/views/system/setting/rotationImage'], resolve),
        name: 'RotationImage',
        meta: {
          title: 'app轮播图',
          icon: 'rotationImage',
          noCache: true
        }
      },
      {
        path: 'rotationImage/edit',
        component: resolve =>
          require(['@/views/system/setting/rotationImage/edit'], resolve),
        name: 'RotationImageEdit',
        meta: {
          title: '编辑app轮播图',
          icon: 'rotationImage',
          noCache: true
        }
      },
      {
        path: '/appContentSetting',
        component: resolve =>
          require(['@/views/system/setting/appContentSetting'], resolve),
        name: 'AppContentSetting',
        meta: {
          title: 'app内容设置',
          icon: 'appContentSetting',
          noCache: true
        }
      },
      {
        path: 'appContentSetting/edit',
        component: resolve =>
          require(['@/views/system/setting/appContentSetting/edit'], resolve),
        name: 'AppContentSettingEdit',
        meta: {
          title: '编辑app内容设置',
          icon: 'appContentSetting',
          noCache: true
        }
      },
      {
        path: '/class',
        component: resolve =>
          require(['@/views/system/setting/class'], resolve),
        name: 'Class',
        meta: { title: '年级与科目', icon: 'class', noCache: true }
      },
      {
        path: 'class/edit',
        component: resolve =>
          require(['@/views/system/setting/class/edit'], resolve),
        name: 'ClassEdit',
        meta: {
          title: '编辑年级与科目',
          icon: 'class',
          noCache: true
        }
      },
      {
        path: 'appStart',
        component: resolve =>
          require(['@/views/system/setting/appStart'], resolve),
        name: 'AppStart',
        meta: {
          title: 'app启动页',
          icon: 'appStart',
          noCache: true
        }
      },
      {
        path: 'device',
        component: resolve =>
          require(['@/views/system/setting/device'], resolve),
        name: 'Device',
        meta: {
          title: '设备码设置',
          icon: 'device',
          noCache: true
        }
      },
      {
        path: 'compassLog',
        component: resolve =>
          require(['@/views/system/setting/compassLog'], resolve),
        name: 'CompassLog',
        meta: {
          title: '操作日志',
          icon: 'compassLog',
          noCache: true
        }
      }
    ]
  },
  {
    path: '/money',
    component: Layout,
    hidden: true,
    children: [
      {
        path: '/cashOut',
        component: resolve =>
          require(['@/views/system/money/cashOut'], resolve),
        name: 'CashOut',
        meta: { title: '提现列表', icon: 'cashOut', noCache: true }
      },
      {
        path: '/appWalletDesc',
        component: resolve =>
          require(['@/views/system/money/appWalletDesc'], resolve),
        name: 'AppWalletDesc',
        meta: {
          title: '钱包说明',
          icon: 'promoterCommissionSetting',
          noCache: true
        }
      },
      {
        path: '/appWalletDesc/edit',
        component: resolve =>
          require(['@/views/system/money/appWalletDesc/edit'], resolve),
        name: 'AppWalletDescEdit',
        meta: {
          title: '钱包说明-编辑内容',
          icon: 'promoterCommissionSetting',
          noCache: true
        }
      },
      {
        path: '/promoterCommissionSetting',
        component: resolve =>
          require(['@/views/system/money/promoterCommissionSetting'], resolve),
        name: 'PromoterCommissionSetting',
        meta: {
          title: '推广员佣金设置',
          icon: 'promoterCommissionSetting',
          noCache: true
        }
      }
    ]
  },
  {
    path: '/order',
    component: Layout,
    hidden: true,
    children: [
      {
        path: '/',
        component: resolve => require(['@/views/system/order'], resolve),
        name: 'Order',
        meta: { title: '订单列表', icon: 'order', noCache: true }
      },
      {
        path: '/order/detail',
        component: resolve => require(['@/views/system/order/detail'], resolve),
        name: 'OrderDetail',
        meta: {
          title: '订单详情',
          icon: '',
          noCache: true
        }
      }
    ]
  },
  {
    path: '/explore',
    component: Layout,
    hidden: true,
    children: [
      {
        path: '/school',
        component: resolve =>
          require(['@/views/system/CompassUniversityInfo/index'], resolve),
        name: 'School',
        meta: { title: '院校管理', icon: 'cashOut', noCache: true }
      },
      {
        path: '/editSchool',
        component: resolve =>
          require(['@/views/system/CompassUniversityInfo/add'], resolve),
        name: 'editSchool',
        meta: { title: '院校管理', icon: 'cashOut', noCache: true }
      },
      {
        path: '/schoolguide',
        component: resolve =>
          require(['@/views/system/CompassUniversityInfo/guide'], resolve),
        name: 'schoolGuide',
        meta: { title: '招生简章', icon: 'cashOut', noCache: true }
      },
      {
        path: '/job_zhuanye/:jobName',
        component: resolve =>
          require(['@/views/system/CompassJobInfo/zhuanye'], resolve),
        name: 'job_zhuanye',
        meta: { title: '职业相关专业', icon: 'cashOut', noCache: true }
      }
    ]
  },
  {
    path: '/CompassDiary',
    component: Layout,
    hidden: true,
    children: [
      {
        path: '/diaryManager',
        component: resolve =>
          require(['@/views/system/CompassDiary/DiaryManager/index'], resolve),
        name: 'diary',
        meta: { title: '日记管理', icon: 'cashOut', noCache: true }
      },
      {
        path: '/diaryDetail',
        component: resolve =>
          require(['@/views/system/CompassDiary/DiaryManager/DiaryDetail'], resolve),
        name: 'diaryDetail',
        meta: { title: '日记详情', icon: 'cashOut', noCache: true }
      },
      {
        path: '/commentDetail',
        component: resolve =>
          require(['@/views/system/CompassDiary/DiaryManager/CommentDetail'], resolve),
        name: 'commentDetail',
        meta: { title: '评论详情', icon: 'cashOut', noCache: true }
      },
      {
        path: '/dataReport',
        component: resolve =>
          require(['@/views/system/CompassDiary/DataReport/index'], resolve),
        name: 'diaryCheck',
        meta: { title: '数据审核', icon: 'cashOut', noCache: true }
      },
      {
        path: '/reportDetail',
        component: resolve =>
          require(['@/views/system/CompassDiary/DataReport/ReportDetail'], resolve),
        name: 'reportDetail',
        meta: { title: '审核详情', icon: 'cashOut', noCache: true }
      },
      {
        path: '/diaryReport',
        component: resolve =>
          require([
            '@/views/system/CompassDiary/DiaryReport/index'
          ], resolve),
        name: 'diaryReport',
        meta: { title: '举报审核', icon: 'cashOut', noCache: true }
      },
      {
        path: '/auditReport',
        component: resolve =>
          require([
            '@/views/system/CompassDiary/DiaryReport/AuditReportDetail'
          ], resolve),
        name: 'auditReport',
        meta: { title: '举报详情', icon: 'cashOut', noCache: true }
      },
    ]
  }
]

export default new Router({
  mode: 'hash', // 去掉url中的#
  scrollBehavior: () => ({ y: 0 }),
  routes: constantRoutes
})
